<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="model.*"
		import="java.util.ArrayList;"%>

<html>
<head>

<title>View Feedback</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<link href="css/style/style.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" media="screen" href="css/theme.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
 
<script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.src.js" type="text/javascript"></script>
<script src="js/jquery-ui.min.js" type="text/javascript"></script>
	


<script type="text/javascript">

$(function () {
    
    
    $("#list4").jqGrid({
    	datatype: 'json', 
    	url : 'feedbackData.do',
    	mtype: "GET",
        colNames:['Receiver','Category', 'Section', 'Content','Date','Provider'],
    	colModel:[ 
    	           {name:'target',index:'target', width:80}, 
    	           {name:'category',index:'category', width:130}, 
    	           {name:'section',index:'section', width:130, }, 
    	           {name:'content',index:'content', width:130, align:"right",}, 
    	           {name:'date',index:'date', width:80, align:"right", sorttype:"date"}, 
    	           {name:'owner',index:'owner', width:80,align:"right"}], 
    	loadonce:true,    	           
        height: 350,
        autowidth: true,
   		rowList : [20,30,50], 
   		rownumbers: true, 
   		gridview: true, pager: '#pager',
   		viewrecords: true, 
   		jsonReader: { repeatitems: false },
		
		loadComplete: function () { },
    	loadError: function (jqXHR, textStatus, errorThrown) {
    	    // remove error div if exist
    	    $('#' + this.id + '_err').remove();

    	    // insert div with the error description before the grid
    	    $(this).closest('div.ui-jqgrid').before(
    	        '<div id="' + this.id + '_err" style="max-width:' + this.style.width +
    	            ';"><div class="ui-state-error ui-corner-all" style="padding:0.7em;float:left;">' +
    	            decodeErrorMessage(jqXHR, textStatus, errorThrown) +
    	            '</div><div style="clear:left"/></div>'
    	    );
    	},
        caption: "View Feedbacks", 
    });
    
    
    
    var decodeErrorMessage = function (jqXHR, textStatus, errorThrown) {
        var htmlBody, errorInfo, i, errorText = '',
            errorIconSpan = '<span class="ui-icon ui-icon-alert" style="float:left; display: inline-block; margin-right: .3em;"></span>';
        if (textStatus) {
            errorText = textStatus;
        }
        if (errorThrown) {
            if (errorText.length > 0) {
                errorText += '<hr/>';
            }
            errorText += errorThrown;
        }
        if (typeof (jqXHR.responseText) === "string") {
            if (jqXHR.responseText.charAt(0) === '[') {
                try {
                    errorInfo = $.parseJSON(jqXHR.responseText);
                    errorText = "";
                    for (i = 0; i < errorInfo.length; i += 1) {
                        if (errorText.length !== 0) {
                            errorText += "<hr/>";
                        }
                        errorText += errorInfo[i].Source + ": " + errorInfo[i].Message;
                    }
                } catch (e) { }
                errorText = errorIconSpan + errorText;
            } else {
                htmlBody = /<body.*?>([\s\S]*)<\/body>/i.exec(jqXHR.responseText);
                if (htmlBody !== null && htmlBody.length > 1) {
                    errorText = htmlBody[1];
                }
            }
        } else {
            errorText = errorIconSpan + errorText;
        }
        return '<div style="float:left">' + errorText + '</div>';
    };
    
    
    var mydata = [ 
                  {"goal":"Goal 1 ","action":"action 1","target":"2013-1-1","complete":"2013-3-3","comment":"com","status":"draft"}, 
                  {"goal":"Goal 2 ","action":"action 2","target":"2013-1-1","complete":"2013-3-3","comment":"com","status":"draft"}, 
                  {"goal":"Goal 3 ","action":"action 3","target":"2013-1-1","complete":"2013-3-3","comment":"com","status":"draft"}, 
                  {"goal":"Goal 4 ","action":"action 4","target":"2013-1-1","complete":"2013-3-3","comment":"com","status":"draft"}, 
                  {"goal":"Goal 5 ","action":"action 5","target":"2013-1-1","complete":"2013-3-3","comment":"com","status":"draft"}
   ]; 

   //for(var i=0;i<=mydata.length;i++) 
   	//jQuery("#list4").jqGrid('addRowData',i+1,mydata[i]);
});
    
    

</script>


</head>
<body>
	
	<div id="container">
		
		<div id="header">
			<img src="css/images/logo.jpg" alt="" id="logo">
			<h1 id="logo-text">View Feedback</h1>
		</div>
		<div id="nav">
			<ul>
				<li><a href="gui.jsp">Home</a></li>
				<li><a href="createFeedback.jsp">Provide Feedback</a></li>
				<li><a href="viewFeed.jsp">Show Feedback</a></li>
				<%
			if (null == session.getAttribute("person")) {
		%>
				<li><a href="#">Self Profile</a></li>
		<%
			} else {
		%>
				<li><a href="profileAcion.do">Self Profile</a></li>
		<%
			}
		%>
				<li><a href="#">About</a></li>
				<li style="border-right: medium none;"><a href="#">Links</a></li>
			</ul>
		</div>
		<div id="site-content">
			<div id="col-left">
		        <div id="tab1">
		            <table id="list4" "><tr><td/></tr></table>
		            <div id="pager"></div>
		        </div>
			</div>
			
			
			<div id="col-right">
				<div style="padding: 30px 10px 10px;">
					<%
						//Employee user = (Employee) session.getAttribute("user");
						if (null == session.getAttribute("person")) {
							String err = (String) request.getAttribute("error");
							if (null != err) {
					%>
							<p style="color: Red"><%=err%></p>
					<%
						request.removeAttribute("error");
							}
					%>
					<form method="post" action="Login.do">
						<h2 class="h-text-2">Login</h2>
						<h3 class="h-text-3">Username</h3>
						<p class="text-2">
							<input type="text" name="username" placeholder="Enter username" size="25">
						</p>

						<h3 class="h-text-3">Password</h3>
						<p class="text-2">
							<input type="password" name="password" size="25">
						</p>
						
						<p><input type="submit" value="submit"></p>
					</form>
				</div>
					<%
						} else {
					%>
							<div align="right"><a href="Login.do?mes=out">Logout</a></div>
							<h4 class="h-text-2">Welcome </h4>
							<h2>${person.username}</h2>
				</div>
				<div>&nbsp;</div>
				<div style="padding: 5px 10px;">
					<h3 class="h-text-2">Contact Info</h3>
				</div>
				<div
					style="padding: 5px 10px 15px; background: rgb(216, 214, 215) none repeat scroll 0%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;">
					<p class="text-2">
						Fullname:  ${person.fullname}<br> <br> 
						Title:  ${person.title.titleName}<br> <br> 
						Email:  ${person.email}<br> <br>
						Fax:  000.000.0000<br> <br> Phone: 000.000.0000/<br>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						000.000.0000
					</p>
				</div>
				
				<br/>
				
					<%
						}
					%>
			</div>
		</div>
		<div id="footer">
			<p>
				@ Copyright 2010. Designed by <a target="_blank"
					href="http://www.htmltemplates.net/">HTML Templates</a>
			</p>
			<ul class="footer-nav">
				<li><a href="#">Home</a></li>
				<li><a href="#">About us</a></li>
				<li><a href="#">Recent articles</a></li>
				<li><a href="#">Email</a></li>
				<li><a href="#">Resources</a></li>
				<li><a href="#">Links</a></li>
			</ul>
		</div>
	</div>
</body>
</html>